# bad sort and a recursive function

array1 = [9,7,-5,4,1,6,3,2,8,0]

def bad_sort (a)
	
	issorted = false
	
	while ( issorted == false )
		issorted = true
		for i in (0..8)	
		do
			j = i + 1
			if ( a[i] > a[j] ) 
			{
				issorted = false
				tmp = a[i]
				a[i] = a[j]
				a[j] = tmp
			}
			
		end
		
	end
	return a	
end

def f (a)
	print "in f"
	return a
end

print "array to sort : ", array1
array_sorted = bad_sort (array1)
print "array sorted  : ", array_sorted


def sum_rec (s)
	a = 0
	if ( s == 0 ) {
		a = 0
	} else {
		t = s - 1
		a = s + sum_rec (t)
	}
	return a
end

N = 100
print "Sum from 1 to ", N
g = sum_rec (N)
# (100 + 1) * 100 / 2 = 101 * 50 = 5050
print g

